<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>广东省传播平台-项目排期查询表</title>
		<style>
		#organizesTree {
			margin-top: 10px;
			border: 1px solid #617775;
			background: #f0f6e4;
			min-width: 180px;
			max-height: 400px;
			overflow-y: scroll;
			overflow-x: auto;
		}
		</style>
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/css/common.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/css/tag.css" />
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/jquery-1.7.2.js">
		</script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js">
		</script>
		
		<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/css/zTreeStyle/zTreeStyle.css" />	
		<link type="text/css" href="<%=request.getContextPath()%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.ztree.core-3.1.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.ztree.excheck-3.1.min.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js">
		</script>
		<script type="text/javascript">
			$(document).ready(function(){
				//禁止退格键 作用于Firefox、Opera    
			    document.onkeypress = banBackSpace;  
			   //禁止退格键 作用于IE、Chrome   
				  document.onkeydown = banBackSpace;  
	         });
	         
	         //处理键盘事件 禁止后退键（Backspace）密码或单行、多行文本框除外 
			function banBackSpace(e){
				//alert(event.keyCode)
			    var ev = e || window.event;//获取event对象   
			    var obj = ev.target || ev.srcElement;//获取事件源     
			    var t = obj.type || obj.getAttribute('type');//获取事件源类型     
			    //获取作为判断条件的事件类型 
			    var vReadOnly = obj.readOnly;
			    var vDisabled = obj.disabled;
			    //处理undefined值情况 
			    vReadOnly = (vReadOnly == undefined) ? false : vReadOnly;
			    vDisabled = (vDisabled == undefined) ? true : vDisabled;
			    //当敲Backspace键时，事件源类型为密码或单行、多行文本的，  
			    //并且readOnly属性为true或disabled属性为true的，则退格键失效  
			    var flag1 = ev.keyCode == 8 && (t == "password" || t == "text" || t == "textarea") && (vReadOnly == true || vDisabled == true);
			    //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效    
			    var flag2 = ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea";
			    //判断    
			    if (flag2 || flag1) 
			        ev.returnValue = false;//这里如果写 return false 无法实现效果 
			}
	         //
			function pageSub(currentPage) {
				var reg = /^\d*?$/;
				var total = ${page.totalPages};
				if(reg.test(currentPage)){
				 	if(currentPage > total){
				 		currentPage = total;
					 }
					 $("#currentPage").val(currentPage);
					 $('#form1').submit();
				} else {
					alert("请输入数字!");
				}
			}
			// 重置
			function resetForm(){
				var city1 = "${logUser.usercity}";
				if(city1 == null){
					city1 = "DG";
				} 
				$("#arrangementStartTime1").val("");
				$("#arrangementEndTime1").val("");
				$("#mediaType1").val("");
				$("#city1").val(city1);
				
				//隐藏报表导出按钮
			    // document.getElementById("exportE").style.display ="none";
			}
			// 提交
			function submitForm(){
				var flag = true;
				$("#arrangementStartTime").val($("#arrangementStartTime1").val());
				$("#arrangementEndTime").val($("#arrangementEndTime1").val());
				$("#mediaType").val($("#mediaType1").val());
				if($("#arrangementStartTime").val() == "" || $("#arrangementStartTime").val() == null){
					alert("开始时间不能为空！");
					flag = false;
				}else if($("#arrangementEndTime").val() == "" || $("#arrangementEndTime").val() == null){
					alert("结束时间不能为空！");
					flag = false;
				}else if($("#mediaType").val() == "" || $("#mediaType").val() == null){
					alert("媒体类型不能为空！");
					flag = false;
				}else{
					var arrangementStartMonth = $("#arrangementStartTime").val().substring(0,7);
					var arrangementEndMonth = $("#arrangementEndTime").val().substring(0,7);
					if(arrangementStartMonth == arrangementEndMonth){
						var arrangementStartDay = $("#arrangementStartTime").val().substring(8,10);
						var arrangementEndDay = $("#arrangementEndTime").val().substring(8,10);
						if(arrangementStartDay > arrangementEndDay){
							alert("开始时间必须小于等于结束时间！");
							flag = false;
						}
					}else{
						alert("时间段不能跨年或跨月！");
						flag = false;
					}
				}
				
				if(flag){
					$("#arrangementStartTime").val($("#arrangementStartTime1").val());
					$("#arrangementEndTime").val($("#arrangementEndTime1").val());
					$("#mediaType").val($("#mediaType1").val());
					$("#city").val($("#city1").val());
					$('#form1').submit();
					
					    	//显示导出报表按钮
    				 document.getElementById("exportE").style.display ="";
				}
			}
			//
			function exportForm(){
				//$("#arrangementStartTime2").val($("#arrangementStartTime1").val());
				//$("#arrangementEndTime2").val($("#arrangementEndTime1").val());
				//$("#mediaType2").val($("#mediaType1").val());
				$('#form2').submit();
			}
	</script>
	</head>
	<body>
	<jsp:include page="../common/top.jsp"></jsp:include>
		<!-- 顶部start -->
		<div id="main">
			<div class="body">
			<jsp:include page="../common/nav.jsp"></jsp:include>
				<!-- 主体 -->
				<h3 style="color:#000000; font-size:14px;height: 20px;
					background: url(images/banners30.jpg) repeat-x;
					margin-bottom: 2px;">项目排期查询表</h3>
				<div class="main_body">
					<form id="form1" action="queryArrangement.action" method="post">
						<table class="condition bg1"
							style="width: 100%; font-size: 14px; font-weight: bold; color: #000000;"
							align="center">
							<tr>
								<td width="8%" style="height: 40px; text-align: right;">
									<label>
										时间段：
									</label>
								</td>
								<td width="29%" style="height: 40px;">
									<input type="text" id="arrangementStartTime1" class="text Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="${arrangementStartTime }" readonly="readonly" />
									-
									<input type="text" id="arrangementEndTime1" class="text Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="${arrangementEndTime }" readonly="readonly" />
								</td>
								<td width="15%" style="height: 40px;">
									<s:select id="mediaType1" list="mediaTypeSelect" listKey="id" listValue="datavalue" headerKey="" headerValue="--媒体类型--" value="mediaType"></s:select>
								</td>
								<td width="15%" style="height: 40px;">
									<s:select id="city1" list="citySelect" listKey="id" listValue="datavalue" value="city"></s:select>
								</td>
								<td width="15%" style="height: 40px;">
									<input type="button" class="btn-title" value="搜索" onclick="submitForm();" />
									&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="button" class="btn-title" value="重置" onclick="resetForm();" />
								</td>
								<td style="height: 40px; text-align: right;" id="exportE" >
									<s:if test="mediaType != null && mediaType != '' && #request.page.totalRecords>0">
										<input type="button" class="btn-title" value="导出"
											onclick="exportForm();" />
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									</s:if>
								</td>
							</tr>
						</table>
						
						<s:if test="mediaType != null && mediaType != ''">
							<div id="list_div"  style="overflow-x: scroll;">
								<div style="width: ${totalFields + 2200}px;">
								<table class="table_list">
									<tr class="bg">
										<th width="200px">
											名称
										</th>
										<th width="150px">
											实际使用金额
										</th>
										<th width="150px">
											次数
										</th>
										<s:iterator value="tableField">
											<th width="150px">
												<s:property/>
											</th>
										</s:iterator>
										
										<th width="200px">
											项目
										</th>
										<th width="150px">
											当前状态
										</th>
										<th width="150px">
											刊例价
										</th>
										<th width="150px">
											折扣(%)
										</th>
										<th width="150px">
											折后刊例
										</th>
										<s:iterator status="stu" begin="startDay" end="endDay" step="1" >
											<th width="30px"><s:property value="#stu.index + startDay"/></th>
										</s:iterator>
										<th width="150px">
											加收
										</th>
										<th width="150px">
											刊例总价
										</th>
										<th width="150px">
											抵扣金额
										</th>
										<th width="150px">
											呈批金额
										</th>
										<th width="150px">
											税金
										</th>
										<th width="150px">
											备注
										</th>
									</tr>
									<s:iterator status="status" value="arrangements">
										<tr>
											<td title="${mediumName }">
												<s:if test="mediumName.length() > 10">
													<s:property value="mediumName.substring(0,10)" />
												</s:if>
												<s:else>
													<s:property value="mediumName" />
												</s:else>
											</td>
											<td>
												--
											</td>
											<td>
												${mediumAmount }
											</td>
											<s:iterator value="tableFieldValue">
												<td>
													<s:property/>
												</td>
											</s:iterator>
											
											<td title="${projectName }">
												<s:if test="projectName.length() > 10">
													<s:property value="projectName.substring(0,10)" />
												</s:if>
												<s:else>
													<s:property value="projectName" />
												</s:else>
											</td>
											<td>
												${mediumStatus }
											</td>
											<td>
												<fmt:formatNumber value="${mediumPrice }"></fmt:formatNumber>
											</td>
											<td>
												<fmt:formatNumber value="${mediumOrientDiscount }"></fmt:formatNumber>
											</td>
											<td>
												<fmt:formatNumber value="${mediumDisPrice }"></fmt:formatNumber>
											</td>
											<!--  -->
											<s:iterator value="mediumArrangementArray" >
												<td>
													<s:property/>
												</td>
											</s:iterator>
											<td>--</td>
											<td>--</td>
											<td>--</td>
											<td>--</td>
											<td>--</td>
											<td>--</td>
										</tr>
										<s:if test="#status.last">
											<tr>
												<td>总计</td>
												<td>--</td>
												<td>
													${totalArrangement.mediumAmount }
												</td>
												<s:iterator value="tableField">
													<td>--</td>
												</s:iterator>
												<td>--</td>
												<td>--</td>
												<td>--</td>
												<td>--</td>
												<td>--</td>
												<s:iterator value="totalArrangement.mediumArrangementArray" >
													<td>
														<s:property/>
													</td>
												</s:iterator>
												
												<td>--</td>
												<td>--</td>
												<td>--</td>
												<td>--</td>
												<td>--</td>
												<td>--</td>
											</tr>
										</s:if>
									</s:iterator>
								</table>
								</div>
							</div>
						<!-- 分页 -->
						<jsp:include page="/jsp/common/page.jsp"></jsp:include>
						</s:if>
						<input type="hidden" id="currentPage" name="currentPage" />
						<input type="hidden" id="city" name="city" value="${city }" />
						<input type="hidden" id="arrangementStartTime" name="arrangementStartTime" value="${arrangementStartTime }" />
						<input type="hidden" id="arrangementEndTime" name="arrangementEndTime" value="${arrangementEndTime }" />
						<input type="hidden" id="mediaType" name="mediaType" value="${mediaType }" /> 
						
					</form>
					<form id="form2" action="exportArrangementExcel.action">
						<input type="hidden" id="city2" name="city" value="${city }" />
						<input type="hidden" id="arrangementStartTime2" name="arrangementStartTime" value="${arrangementStartTime }" />
						<input type="hidden" id="arrangementEndTime2" name="arrangementEndTime" value="${arrangementEndTime }" />
						<input type="hidden" id="mediaType2" name="mediaType" value="${mediaType }" />
					</form>
				</div>
			</div>
			</div>
		<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
	</body>
</html>
